package org.gurms.common.config;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class GlobalConfig {

    private static final Logger logger = LoggerFactory.getLogger(GlobalConfig.class);
    private static final ResourceBundle config = ResourceBundle.getBundle("gurms-config");

    //-------------分页------------
    public static int MIN_PAGESIZE = getIntConfig("min_pagesize");
    public static int MAX_PAGESIZE = getIntConfig("max_pagesize");
    
    //-------------struts2------------
    public static String INTERCEPTOR_IGNORE_ACTION = getNormalConfig("interceptor_ignore_action");
    public static String INTERCEPTOR_IGNORE_METHOD = getNormalConfig("interceptor_ignore_method");
    public static String SYS_LAYOUT = getImportantConfig("layout_mode");

    //------------数据库------------
    public static String ID_SYS_ROLE_SYSTEM = getNormalConfig("id_sys_role_system");
    public static String ID_SYS_MENU_ROOT   = getNormalConfig("id_sys_menu_root");
	
    private GlobalConfig(){}
    
	public static String getNormalConfig(String key){
		String val = "";
		try{
			val = config.getString(key);
		}catch(MissingResourceException mre){
			logger.warn("can't find [" + key + "] from grums-config.properties");
		}
		return val;
	}
	
	public static String getImportantConfig(String key){
		return config.getString(key);
	}
	
	public static int getIntConfig(String key){
		String number = getImportantConfig(key);
		return Integer.parseInt(number);
	}
}
